/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: XMQ
 * Date: 2022-06-01
 * Time: 15:29
 */
class MyArray2<T>{
//    public Object[] objects = new Object[10];
    public T[] array = (T[]) new Object[10];
    public T getVal(int pos){
        return array[pos];
    }
    public void setVal(int pos,T val){
        array[pos] = val;
    }
}
public class Test2 {
    public static void func(){
        System.out.println("类方法");
    }
    public static void main(String[] args) {

        MyArray2<String> myArray = new MyArray2<String>();
        myArray.setVal(0,"abc");
        myArray.setVal(1,"hello");

        String s = myArray.getVal(1);
        System.out.println(s);

        MyArray2<Integer> myArray2 = new MyArray2<Integer>();
        myArray2.setVal(0,1);
        myArray2.setVal(1,2);

        System.out.println(myArray2.getVal(1));
    }
}
